using System;
using System.Data.Entity.ModelConfiguration;
using System.Data.Common;
using System.Data.Entity;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;

namespace SampleApp.Domain.Map
{
    public class SysUserMap : EntityTypeConfiguration<SysUser>
    {
        public SysUserMap()
        {
            this.ToTable("exp_t_application_user");
            this.HasKey(t => t.UserCode);
            this.Property(t => t.UserCode).HasDatabaseGeneratedOption(DatabaseGeneratedOption.None);
            this.Property(t => t.UserCode).HasColumnName("user_code");
            this.Property(t => t.UserEmail).HasColumnName("user_email");
            this.Property(t => t.UserName).HasColumnName("user_name");
            this.Property(t => t.Remark).HasColumnName("remark");
            this.Property(t => t.Password).HasColumnName("user_password");
            this.Property(t => t.DeptCode).HasColumnName("deptcode");

            this.HasMany(p => p.UserRoleList)
                .WithRequired(c => c.SysUser)
                .HasForeignKey(c => c.UserCode);
        }
    }
}

